{include file=member.header.html}
<script type="text/javascript">
function orderHover(o) {
    $(o).addClass('order-hover');
}
function orderOut(o) {
    $(o).removeClass('order-hover');
}
$(function() {
    $('#add_time_from_date').datepicker({
        dateFormat: 'yy-mm-dd'
    });
    $('#add_time_to_date').datepicker({
        dateFormat: 'yy-mm-dd'
    });

    $('.checkall_s').bind('click', function() {
    	  var if_check = $(this).attr('checked');
    	  if($('input[enctype="cancel"]').length>0){
    	  	$('input[enctype="cancel"]').attr('checked', if_check);
    	  }else{
    	  	wl.sConfirm({'info':'没有符合条件的订单','cancel':true});
    	  	$(this).attr('checked',false);
    	  }
    });
    $('body').bind('click', function(event) {
	    var target = $(event.target);
	    if (target.is('input[enctype="cancel"]')) {
	        var if_check = target.attr('checked');
	        if (if_check) {
	            var same = true;
	            $('input[enctype="cancel"]').each(function() {
	                if ($(this).attr('checked') != if_check) {
	                    same = false;
	                }
	            });
	            if (same) {
	                $('.checkall_s').attr('checked', true);
	            }
	        } else {
	            $('.checkall_s').attr('checked', false);
	        }
	    }
	});

    $('a[ectype="batchcancel"]').click(function() {
        if ($('.checkitem:checked').length == 0) {
        	wl.sConfirm({'info':'没有符合条件的订单','cancel':true});
            return false;
        }
        if ($(this).attr('presubmit')) {
            if (!eval($(this).attr('presubmit'))) {
                return false;
            }
        }
        var items = '';
        $('.checkitem:checked').each(function() {
            items += this.value + ',';
        });
        items = items.substr(0, (items.length - 1));

        var uri = $(this).attr('uri');
        uri = uri + '&' + $(this).attr('name') + '=' + items;
        var id = 'seller_order_cancel_order';
        var title = $(this).attr('dialog_title') ? $(this).attr('dialog_title') : '';
        var width = '500';
        ajax_form(id, title, uri, width);
    });

    /*$(".check_shipping").click(function()
    {
        var expressid = $(this).attr("expressid");
        var expressno = $(this).attr("expressno");
        var expresstype = $(this).attr("expresstype");
        $.get(SITE_URL+"/api/kuaidi/index.php",{com:expressid,nu:expressno,type:expresstype},
            function(data){
                if(data)
                {
                    window.open(data);
                }
                else
                {
                    alert(data);
                }

            });
        return false;
    });*/
});
</script>
<div class="content f-cb">
	{include file=path.html}
  {include file=member.menu.html}
	<!-- 内容右边栏 -->
	<div class="con-r-global">
		<ul id="con-order-nav" class="con-order-nav f-cb">
			<li class="nav-li">
				<a href="index.php?app=seller_order&type=all_orders" class="{if $gets['type'] eq 'all_orders'}current{/if}">全部订单</a>
			</li>
			<li class="nav-li">
				<a href="index.php?app=seller_order&type=pending" class="{if $gets['type'] eq 'pending'}current{/if}">待付款</a>
				{if $seller_stat.submitted>0}
				<span class="nav-note f-cb"> <i>{$seller_stat.submitted}</i>
				</span>
				{/if}
			</li>
			<li class="nav-li">
				<a href="index.php?app=seller_order&type=accepted" class="{if $gets['type'] eq 'accepted'}current{/if}">待发货</a>
				{if $seller_stat.accepted>0}
				<span class="nav-note f-cb"> <i>{$seller_stat.accepted}</i>
				</span>
				{/if}
			</li>
			<li class="nav-li">
				<a href="index.php?app=seller_order&type=shipped" class="{if $gets['type'] eq 'shipped'}current{/if}">待确认收货</a>
				{if $seller_stat.shipped>0}
				<span class="nav-note f-cb">
					<i>{$seller_stat.shipped}</i>
				</span>
				{/if}
			</li>
			<li>
				<a href="index.php?app=seller_returns">退款退货</a>
                {if $seller_stat.returns>0}
				<span class="nav-note f-cb">
					<i>{$seller_stat.returns}</i>
				</span>
				{/if}
			</li>
			<li>
				<a href="index.php?app=seller_order&type=finished" class="{if $gets['type'] eq 'finished'}current{/if}">交易成功</a>
				{if $seller_stat.finished>0}
				<span class="nav-note f-cb">
					<i>{$seller_stat.finished}</i>
				</span>
				{/if}
			</li>
			<li>
				<a href="index.php?app=seller_order&type=canceled" class="{if $gets['type'] eq 'canceled'}current{/if}">交易关闭</a>
				{if $seller_stat.canceled>0}
				<span class="nav-note f-cb">
					<i>{$seller_stat.canceled}</i>
				</span>
				{/if}
			</li>
		</ul>
        <div class="order-search f-cb">
        <form method="get" class="f-cb">
             <div class="order-search-left">
                <input type="hidden" name="app" value="seller_order" />
                <input type="hidden" name="act" value="index" />
                <p><span>下单时间：从 <input class="queryInput width2 b-radius pick_date" type="text" value="{$query.add_time_from_date}" id="add_time_from_date" name="add_time_from_date"  /> 日 <select class="querySelect b-radius" name="add_time_from_hh">{html_options options=$time_hh_list selected=$query.add_time_from_hh}
                </select> 时 <input class="queryInput width18  b-radius" type="text" value="{$query.add_time_from_ii}" maxlength="2" onkeyup="this.value=this.value.replace(/\D/g,'')" name="add_time_from_ii"  />  分
                到: <input class="queryInput width2  b-radius  pick_date" type="text" value="{$query.add_time_to_date}" id="add_time_to_date" name="add_time_to_date"  /> 日 <select class="querySelect  b-radius" name="add_time_to_hh">{html_options options=$time_hh_list selected=$query.add_time_to_hh}
                </select> 时 <input class="queryInput  width18  b-radius" type="text" value="{$query.add_time_to_ii}" maxlength="2" onkeyup="this.value=this.value.replace(/\D/g,'')" name="add_time_to_ii"  />  分
                </span>
                <span>订单状态：<select class="querySelect b-radius" name="status">
                    <option value="">全部</option>
                    {html_options options=$order_status_list selected=$query.status}
                </select>
                </span>
                <span>评价状态：<select class="querySelect b-radius" name="evaluation_status">
                    <option value="">全部</option>
                    {html_options options=$evaluation_status_list selected=$query.evaluation_status}
                </select>
                </span></p>
                <p><span>买家：<input class="queryInput b-radius width8" placeholder="用户名/收货人姓名" type="text" name="search_name" value="{$query.search_name|escape}" /></span><span>订单编号：<input class="queryInput b-radius width8" placeholder="订单号" type="text" name="order_sn" value="{$query.order_sn}" /></span><span>商品名称：<input class="queryInput b-radius width8" placeholder="商品名称/货号" type="text" name="goods_name" value="{$query.goods_name|escape}" /></span></p>
            </div>
            <div class="order-search-right"><input type="submit" class="subbtn" value="搜索" /></div>
        </form>
        </div>
		<!--{if $orders}-->
		<table class="order-show-title" width="100%">
			<tr>
				<th width="320">
					<input id="all" type="checkbox" class="checkall_s" />
					<label for="all">
						<span class="all">{$lang.checkall}</span>
					</label>
					&nbsp; | &nbsp;
					<a href="javascript:;" class="delete" ectype="batchcancel" uri="index.php?app=seller_order&act=cancel_order" name="order_id">{$lang.cancel_order}</a>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;商品信息
				</th>
				<th width="160">商品规格</th>
				<th width="60">数量</th>
				<th width="130" class="order-th">实付总额(元)</th>
				<th width="140" class="order-th">订单状态</th>
				<th class="order-th">订单操作</th>
			</tr>
		</table>
		<!--{/if}-->

		<!-- 循环开始 -->
		<!--{foreach from=$orders item=order}-->
		<table class="order-show-each" width="100%" onmousemove="orderHover(this)" onmouseout="orderOut(this)">
			<tr>

				<th>
					<input type="checkbox" value="{$order.order_id}" class="checkitem" {if $order.status eq ORDER_PENDING}enctype="cancel"{else}disabled="disabled" {/if} /> 订单号：{$order.order_sn}
				</th>
				<th>下单时间：{$order.add_time|date:Y-m-d H:i}</th>
				<th>买家：{$order.buyer_name|escape}</th>
				<th>
					<!--{if $order.member_info.im_qq}-->
					<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin={$order.member_info.im_qq}&site=qq&menu=yes">
						<img src="{res file=images/member/qq.jpg}" alt="" />
					</a>
					<!--{/if}-->
					&nbsp;&nbsp;
					<!--{if $order.member_info.im_aliww}-->
					<a target="_blank" href="http://www.taobao.com/webww/ww.php?ver=3&touid={$order.member_info.im_aliww}&siteid=cntaobao&status=1&charset=utf-8">
						<img src="{res file=images/member/wangwang.jpg}" alt="" />
					</a>
					<!--{/if}-->
				</th>
				<th>&nbsp;</th>
				<th>&nbsp;</th>
				<th>&nbsp;</th>
			</tr>
			<!--{foreach from=$order.order_goods key=k item=v}-->
			<tr>
				<td width="140" valign="top">
					<div class="goods-show-img">
						<a href="{jsurl index.php?app=goods&id=$v.goods_id}" target="_blank">
							<img src="{$v.goods_image}" alt="" height="100"></a>
					</div>
				</td>
				<td width="160" valign="top">
					<p>
						<a href="{jsurl index.php?app=goods&id=$v.goods_id}" target="_blank" class="linkbtn">{$v.goods_name}</a>
					</p>
					<p>货号：{$v.sku|escape}</p>
					<p>价格：{$v.price} 元/件</p>
				</td>
				<td width="160" valign="top">
					<ul>
						<li>{$v.specification}</li>
					</ul>
				</td>
				<td width="60" valign="top" align="center">{$v.quantity}</td>
				<!--{if $order.index eq $k}-->
				<td width="130" valign="top">
					<dl>
                                                {if $order.old_order_amount gt 0}<dt><strike>{$order.old_order_amount|price}</strike></dt>{/if}
						<dt>{$order.order_amount|price}</dt>
                                                <!--{if $order.is_mobile}--><dd class="mobile-icon"></dd><!--{/if}-->
					</dl>
				</td>
				<td width="140" valign="top">
					<dl>
						<dt>
							{$order.status|modifier:order_status}
							<!--{if $order.evaluation_status}-->
							,&nbsp;{$lang.already_evaluate}
							<!--{/if}-->
						</dt>
						<!--dd>货款已到万菱账户担保中</dd-->
					<!--{if $order.status eq 11}-->
					<dd>距离订单失效时间：</dd>
					<dd class="lxftime" endtime="<!--{$order.endtime}-->"></dd>
					<!--{/if}-->
					<dd>
						<a href="index.php?app=seller_order&act=view&order_id={$v.order_id}" target="_blank" class="linkbtn">订单详情</a>
					</dd>
                    <!--{if $order.shipping_code and $order.ship_time gt 0}-->
                    <dd><a target="_blank" href="{url app=check_shipping&com=$order.shipping_code&nu=$order.invoice_no&type=1}" expressid="{$order.shipping_code}" expressno="{$order.invoice_no}" expresstype="1" class="linkbtn check_shipping">查看物流</a></dd>
                    <!--{/if}-->
				</dl>
			</td>
			<!--{if $order.status eq 20}-->
			<td valign="top" align="center">
				<ul>
					<li>
						<a href="javascript:;" class="subbtnhs btn1" ectype="dialog" dialog_title="{$lang.shipped_order}" dialog_id="seller_order_shipped" uri="index.php?app=seller_order&amp;act=shipped&amp;order_id={$order.order_id}&ajax"  dialog_width="580" id="order{$order.order_id}_action_shipped"{if $order.status neq ORDER_ACCEPTED} style="display:none"{/if}>马上发货</a>
					</li>
					<!--li>
					<a href="" class="linkbtn">备忘</a>
				</li-->
			</ul>
		</td>
                <!--{elseif $order.status eq 30}-->
                <td valign="top" align="center">
                        <ul>
                            <li>
                                    <a href="javascript:;" class="linkbtn" ectype="dialog" dialog_title="{$lang.shipped_order}" dialog_id="seller_order_shipped" uri="index.php?app=seller_order&amp;act=shipped&amp;order_id={$order.order_id}&ajax"  dialog_width="580" id="order{$order.order_id}_action_shipped">修改发货单</a>
                            </li>
			</ul>
                </td>
		<!--{elseif $order.status eq 11}-->
		<td valign="top" align="center">
			<ul>
				<li>
					<a href="javascript:;" ectype="dialog" url="index.php?app=seller_order&amp;act=cancel_order&order_id={$v.order_id}&cancel=1" uri="index.php?app=seller_order&amp;act=cancel_order&order_id={$v.order_id}&ajax" dialog_title="取消订单" dialog_id="seller_order_cancel_order" dialog_width="400" id="order1_action_cancel" class="linkbtn">关闭订单</a>
				</li>
				<li>
					<a href="javascript:;" class="btn1 linkbtn" uri="index.php?app=seller_order&amp;act=adjust_fee&amp;order_id={$v.order_id}&ajax" dialog_width="450" dialog_title="调整费用" ectype="dialog"  dialog_id="seller_order_adjust_fee" id="order1_action_adjust_fee">修改订单</a>
				</li>
				<!--li>
				<a href="" class="linkbtn">备忘</a>
			</li-->
		</ul>
	</td>
	<!--{else}-->
	<td valign="top" align="center"></td>
	<!--{/if}-->
	<!--{else}-->
	<td width="130" valign="top">&nbsp;</td>
	<td width="140" valign="top">&nbsp;</td>
	<td valign="top" align="center">&nbsp;</td>
	<!--{/if}-->
</tr>
<!--{/foreach}-->
</table>
<!--{foreachelse}-->
<div style="padding:20px 0;text-align:center;border:1px solid #cccccc;margin-top:20px;font-weight:bold;">{$lang.no_records}</div>
<!--{/foreach}-->
<iframe name="seller_order" style="display:none;"></iframe>
<div class="goods-page">{include file=goods.page.bottom.html}</div>

</div>
</div>
<script>
  function lxfEndtime(){
          $(".lxftime").each(function(){
                var lxfday=$(this).attr("lxfday");//用来判断是否显示天数的变量
                var endtime = new Date($(this).attr("endtime")).getTime();//取结束日期(毫秒值)
                var nowtime = new Date().getTime();        //今天的日期(毫秒值)
                var youtime = endtime-nowtime;//还有多久(毫秒值)
                var seconds = youtime/1000;
                var minutes = Math.floor(seconds/60);
                var hours = Math.floor(minutes/60);
                var days = Math.floor(hours/24);
                var CDay= days ;
                var CHour= hours % 24;
                var CMinute= minutes % 60;
                var CSecond= Math.floor(seconds%60);//"%"是取余运算，可以理解为60进一后取余数，然后只要余数。
                if(endtime<=nowtime){
							$(this).html("<span><i>0</i></span>时<span><i>0</i></span>分<span><i>0</i></span>秒")//如果结束日期小于当前日期就提示过期啦
							var c_url = $('#order1_action_cancel').attr('url');
							//$.get(c_url,function(data){
								//alert(data.status)
							//});
                        }else{
                                if($(this).attr("lxfday")=="no"){
                                        $(this).html("<span><i>"+CHour+"</i></span>时<span><i>"+CMinute+"</i></span>分<span><i>"+CSecond+"</i></span>秒");          //输出没有天数的数据
                                        }else{
                        $(this).html("<span><i>"+days+"</i></span>天<span><i>"+CHour+"</i></span>时<span><i>"+CMinute+"</i></span>分<span><i>"+CSecond+"</i></span>秒");          //输出有天数的数据
                                }
                        }
          });
   setTimeout("lxfEndtime()",1000);
  };
$(function(){
      lxfEndtime();
   });
</script>
{include file=footer.html}